<?php


namespace App\Services;

use App\Models\CrontabModel;

/**
 * 定时任务-服务类
 * @author 牧羊人
 * @since 2020/8/30
 * Class CrontabService
 * @package App\Services
 */
class CrontabService extends BaseService
{
    /**
     * 构造函数
     * @author 牧羊人
     * @since 2020/8/30
     * CrontabService constructor.
     */
    public function __construct()
    {
        $this->model = new CrontabModel();
    }

    /**
     * 添加或编辑
     * @return array
     * @since 2020/8/30
     * @author 牧羊人
     */
    public function edit()
    {
        $data = request()->all();
        // 开始时间
        if (isset($data['start_time']) && $data['start_time']) {
            $data['start_time'] = strtotime($data['start_time']);
        }
        // 结束时间
        if (isset($data['end_time']) && $data['end_time']) {
            $data['end_time'] = strtotime($data['end_time']);
        }
        // 执行时间
        if (isset($data['execute_time']) && $data['execute_time']) {
            $data['execute_time'] = strtotime($data['execute_time']);
        }
        return parent::edit($data); // TODO: Change the autogenerated stub
    }
}
